#include "Grid.h"
#include "Square.h"

//convert mouse XY to row/column XY
XY Grid::SquareOver(XY pos)
{
	//local mouse co-ordinates
	pos -= GRID_TOP_LEFT;
	//grid co-ordinates
	pos /= SQUARE_SIZE;
	return pos;
}

void Grid::PrepDraw()
{
	XY pos;
	for(int i=0;i<BOARD_SIZE;++i)
	{
		for(int j=0;j<BOARD_SIZE;++j)
		{
			XY ij(i, j);
			//	   grid co-ordinates   window co-ordinates
			pos = ( (ij*SQUARE_SIZE) + GRID_TOP_LEFT );
			square[i][j]->setPos(pos);
		}
	}
}

void Grid::Draw()
{
	for(int i=0;i<BOARD_SIZE;++i)
		for(int j=0;j<BOARD_SIZE;++j)
			square[i][j]->Draw();
}